package com.hsy.crm.web.web.system;

import com.hsy.crm.web.domain.cm.Response;
import com.hsy.crm.web.domain.cm.Unified;
import com.hsy.crm.web.domain.entity.Role;
import com.hsy.crm.web.domain.vo.role.RoleAuthorityVo;
import com.hsy.crm.web.domain.vo.role.RoleListVo;
import com.hsy.crm.web.domain.vo.role.RolePageVo;
import com.hsy.crm.web.service.impl.RoleService;
import com.hsy.crm.web.web.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RestController
@RequestMapping("/role")
public class RoleAction extends BaseAction {

    @Autowired
    RoleService roleService;

    @RequestMapping("/insert")
    public String insert(Role role) {
        return Response.body(Unified.newInstance(roleService.insert(role,Boolean.TRUE)));
    }

    @RequestMapping("/update")
    public String update(Role role) {
        return Response.body(Unified.newInstance(roleService.update(role,Boolean.TRUE)));
    }

    @RequestMapping("/delete")
    public String delete(Role role) {
        return Response.body(roleService.deleteRole(role));
    }

    @RequestMapping("/select")
    public String select(Role role) {
        return Response.body(Unified.newInstance(roleService.select(role)));
    }

    @RequestMapping("/get")
    public String get(Role role) {
        return Response.body(Unified.newInstance(roleService.selectOne(role)));
    }

    @RequestMapping("/page")
    public String page(RolePageVo rolePageVo) {
        return Response.body(roleService.page(rolePageVo));
    }

    @RequestMapping("/userRolePage")
    public String userRolePage(RolePageVo rolePageVo) {
        return Response.body(roleService.userRolePage(rolePageVo));
    }

    @RequestMapping("/authority")
    public String authority(RoleAuthorityVo authorityVo) {
        return Response.body(roleService.authority(authorityVo));
    }

    @RequestMapping("/findMenus")
    public String findMenus(RoleListVo roleListVo) {
        return Response.body(roleService.findMenus(roleListVo));
    }

}
